package com.cdream.common;

import com.cdream.common.idempotent.autoconfig.IdempotentProperties;
import com.cdream.common.idempotent.core.IdempotentStrategy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @author cdream
 * @date 2023/1/4
 */
@Configuration
@ConditionalOnClass(RedisOperations.class)
public class RedisIdempotentStrategyAutoConfiguration {

    @Bean
    public IdempotentStrategy redisTemplateIdempotentStrategy(StringRedisTemplate stringRedisTemplate, IdempotentProperties properties) {
        return new RedisIdempotentStrategyImpl(stringRedisTemplate,properties);
    }
}
